From 4a07d5601afb94fa0928502016bfe2507cad9ded Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sun, 24 May 2020 10:39:01 -0600 Subject: [PATCH] teach gdb reader to read autoroute information. (#566) --- gdb.cc | 33 +++++++- reference/gdb-sample-v3-autoroute.gdb | Bin 0 -> 1767 bytes reference/gdb-sample-v3-autoroute.gpx | 108 ++++++++++++++++++++++++++ testo.d/gdb.test | 4 + 4 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 reference/gdb-sample-v3-autoroute.gdb create mode 100644 reference/gdb-sample-v3-autoroute.gpx diff --git a/gdb.cc b/gdb.cc index d32664cab..681f89c79 100644 --- a/gdb.cc +++ b/gdb.cc @@ -19,6 +19,9 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + A format description obtained from reverse-engineering is at + https://www.memotech.franken.de/FileFormats/Garmin_MPS_GDB_and_GFI_Format.pdf */ #include // for fabs @@ -840,7 +843,35 @@ read_route() int color_idx = FREAD_i32; rte->line_color.bbggrr = gt_color_value(color_idx); - FREAD(buf, 1); /* ?????????????????????????????????? */ + + int autoroute = FREAD_C; + if (autoroute == 1) { + FREAD(buf, 6); /* unknown bytes */ + int route_style = FREAD_C; + int calc_type = FREAD_i32; + int vehicle_type = FREAD_C; + int road_selection = FREAD_i32; + double driving_speed[5]; + driving_speed[0] = FREAD_DBL; + driving_speed[1] = FREAD_DBL; + driving_speed[2] = FREAD_DBL; + driving_speed[3] = FREAD_DBL; + driving_speed[4] = FREAD_DBL; + FREAD(buf, 8); /* unknown bytes */ +#if GDB_DEBUG + DBG(GDB_DBG_RTE, 1) + printf(MYNAME "-rte_pt: autoroute info: route style %d, calculation type %d, vehicle type %d, road selection %d\n" + " driving speeds (kph) %.0f, %.0f, %.0f, %.0f, %.0f\n", + route_style, calc_type, vehicle_type, road_selection, + driving_speed[0], driving_speed[1], driving_speed[2], driving_speed[3], driving_speed[4]); +#else + Q_UNUSED(route_style); + Q_UNUSED(calc_type); + Q_UNUSED(vehicle_type); + Q_UNUSED(road_selection); + Q_UNUSED(driving_speed); +#endif + } rte->rte_desc = fread_cstr(); #if 0 diff --git a/reference/gdb-sample-v3-autoroute.gdb b/reference/gdb-sample-v3-autoroute.gdb new file mode 100644 index 0000000000000000000000000000000000000000..01764df71e40e45b3cf270a8cf401a56d2caf289 GIT binary patch literal 1767 zcmah~O-vI(6n+azVj(7Kgqs~gJORn>QfY!Q*;ddPttL<;#)P=gMK+c#Zd;U#a3jXR z$%7sZ(ZEe_deWN*4`@92cQHl}9*l7EVuJ6R{p+@X({$#|>zntz|K`fWlT*}0M1wPQ zjE~F%Wuj^q3-ffwnh=^MbX8YLQwP+(0qq23&9ZgcoSCKDEIX#Eszz;0QD^>WqlT(4G#1E`Jyu$;cDQ z3>FcnOPtIVP9{Y!5+l`O(VjCMk-z2ih}=+*P*eT=sU9KKAnkB}nZLD?lp6v@qzAWX zDaOm!M-j4T0W0#oRf5%t8avoMGmJe%^@{1fJ-BQ$dCd z;{ko!B5(T{B~tD;ZrH&)5slI@1NNQ_2slOr3}}`H?1RINxNRKHG{Wikwl5?j3>G3B z!`*vA02iYoavbT2l!qvrtot2se=_j~#1AH3F%dL-&9jgdvt-Yau}h*uO<~VSJlQ>9 zVan9_TUUN?C0@AT1V-WXi>tB9ASnMoJSkicf<=m4xF16BZk|efSlzs8G<7eve_EL| j&ZqBYt{u0H)vgzRmr}Dv_xh2ygU?+959C7mUMA%qGr + + + + + 37.273 + 0001 + Get on Manor Ln and drive south + Get on Manor Ln and drive south + Waypoint + + + 37.160 + 0002 + Turn left onto Us1 + Turn left onto Us1 + Waypoint + + + 40.863 + 0003 + Turn right onto Miramar Ave + Turn right onto Miramar Ave + Waypoint + + + 40.180 + 0004 + 0004 + 0004 + Waypoint + + + + 7 Manor Ln + 7 Manor Ln +Sullivan Twn, ME, 04664, USA + 7 Manor Ln +Sullivan Twn, ME, 04664, USA + Flag, Blue + + + + Acadia Bay Inn + Acadia Bay Inn +12 Miramar Ave +Sullivan Twn, Maine, 04664, United States +207-422-0127 + Acadia Bay Inn +12 Miramar Ave +Sullivan Twn, Maine, 04664, United States +207-422-0127 + Lodging + + + 7 Manor Ln to Acadia Bay Inn + + + 7 Manor Ln + 7 Manor Ln +Sullivan Twn, ME, 04664, USA + 7 Manor Ln +Sullivan Twn, ME, 04664, USA + Flag, Blue + + + 37.273 + 0001 + Get on Manor Ln and drive south + Get on Manor Ln and drive south + Waypoint + + + 37.160 + 0002 + Turn left onto Us1 + Turn left onto Us1 + Waypoint + + + 40.863 + 0003 + Turn right onto Miramar Ave + Turn right onto Miramar Ave + Waypoint + + + 40.180 + 0004 + 0004 + 0004 + Waypoint + + + + Acadia Bay Inn + Acadia Bay Inn +12 Miramar Ave +Sullivan Twn, Maine, 04664, United States +207-422-0127 + Acadia Bay Inn +12 Miramar Ave +Sullivan Twn, Maine, 04664, United States +207-422-0127 + Lodging + + + diff --git a/testo.d/gdb.test b/testo.d/gdb.test index 847518388..05aa812b5 100644 --- a/testo.d/gdb.test +++ b/testo.d/gdb.test @@ -25,3 +25,7 @@ compare ${REFERENCE}/gdb-sample.gpx ${TMPDIR}/gdb-sample_v2.gpx gpsbabel -i gdb,via -f ${REFERENCE}/gdb-sample-v3.gdb -o gpx -F ${TMPDIR}/gdb-sample_v3.gpx compare ${REFERENCE}/gdb-sample.gpx ${TMPDIR}/gdb-sample_v3.gpx + +# don't choke if autoroute information is present. +gpsbabel -i gdb -f ${REFERENCE}/gdb-sample-v3-autoroute.gdb -o gpx -F ${TMPDIR}/gdb-sample-v3-autoroute.gpx +compare ${REFERENCE}/gdb-sample-v3-autoroute.gpx ${TMPDIR}/gdb-sample-v3-autoroute.gpx -- 2.30.2